home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
INFO
/
DOSTIPS6.ZIP
/
DOSFIND
< prev
next >
Wrap
Text File
|
1987-03-02
|
4KB
|
103 lines
Switched-On FIND
(PC Magazine Vol 6 No 6 March 31, 1987 User-to-User)
The PC Lab Notes column on advanced FIND techniques (PC Magazine
Vol 5 No 20) explained a method of using the DOS FOR...IN...DO command
to handle FIND wildcards. There aer two ways to improve this batch
procedure.
The PC Lab Notes procedure lacked a method for specifying different
combinations of wildcards (such as *.PAS), and couldn't add FIND
switches such as /C or /V. The WILDFILE.BAT allows both of these:
ECHO OFF
IF %2!==! GOTO ERROR
FOR %%A IN (%2) DO FIND%3 "%1" %%a
GOTO END
:ERROR
ECHO The proper command syntax is:
ECHO WILDFIND string filename [switches]
:END
The WILDFIND syntax is slightly different from the DOS FIND
syntax. First, the string to search for is not enclosed in quotation
marks. Second, the optional switches go at the end of the command line
instead of immediately after the command name. As with DOS, switches
are separated from the filename by at least one space.
For example, to hunt for the string VAR1 in all files with the
extension PAS, and then count but not display each occurrence of the
string, type:
WILDFIND VAR1 *.PAS /C
Editor's Note: FIND and the FOR...IN...DO command are two of the
most powerful DOS commands, especially when joined together. However,
each has drawbacks. An annoying one is the awful /N numbering system.
If you wanted a cleanly numbered list of all the *.TXT files on your
disk, you might think you could type:
DIR *.TXT | FIND /N " " > NUMLIST
However, FIND won't put spaces between the numbers and the actual
entries, and it won't align the columns properly if you're going from
single-digit to double-digit numbers (or double to triple, if you
have lots of files).
Worse, since the /N switch is really designed for searching through
program source code, or phone directories, and not redirected DOS
outputs, it will choke on empty lines and end up misnumbering
everything. A better way might be to get into DOS and redirect a
directory of text files into a file called IN:
DIR *.TXT | FIND "-" > IN
and then run a small BASIC program NUMBER.BAS:
100 OPEN "IN" FOR INPUT AS #1
110 OPEN "OUT" FOR OUTPUT AS #2
120 WHILE NOT EOF()
130 LINE INPUT #1,A$
140 PRINT #2,USING "###";A+1;
150 PRINT #2,CHR$(32);A$
160 A=A+1:WEND:CLOSE
Another irksome thing about FIND is the "-----------" line it
prints when displaying anything. This is easy to get rid of by going
into the code with DEBUG and replacing each hyphen with a backspace.
First, rename FIND.EXE to F, and load DEBUG:
REN FIND.EXE F
DEBUG F
When you see the DEBUG "-" hyphen prompt, type RCX and hit the Enter
key twice. DEBUG will respond with something like:
CX 1903
:
Then, when you see the hyphen prompt again, type:
S 100 L1903 "-----------"
(substituting the actual hex number DEBUG reported after the CX in the
previous command, if it's different from 1903). DEBUG will print an
address that looks something like:
2F71:19F7
Ignore the first four numbers (the ones to the left of the colon).
Take the four rightmost hex numbers and enter them in place of the
xxxx below:
E xxxx 8 8 8 8 8 8 8 8 8 8 8
For instance, you'd enter E 19F7 8 8 8 8 8 8 8 8 8 8 8 if DEBUG
returned the 2F71:19F7 mentioned earlier. Then type:
W
Q
REN F FIND.EXE
(hitting the Enter key after each line) and your new, patched FIND
won't ever print the ----------- line again when displaying the
strings you've searched for.